package com.ss.android.f.b.a.a;

import android.content.Context;
import android.content.SharedPreferences;
import android.text.TextUtils;
import com.bytedance.common.utility.Logger;

public final class SharePreferenceCacheHandler extends c {
    private final SharedPreferences a;

    public SharePreferenceCacheHandler(Context arg3) {

        if(arg3 == null) {
            throw new IllegalArgumentException("context can\'t be null");
        }

        this.a = arg3.getSharedPreferences("snssdk_openudid", 0);
    }

    protected final String a(String arg5) {
        String v0 = this.c(arg5);
        if(Logger.debug()) {
            Logger.d("SharePreferenceCacheHandler", "getCachedString key = " + arg5 + " value = " + v0);
        }

        return v0;
    }

    protected final void a(String arg4, String arg5) {
        if(Logger.debug()) {
            Logger.d("SharePreferenceCacheHandler", "cacheString key = " + arg4 + " value = " + arg5);
        }

        this.g(arg4, arg5);
    }

    protected final void a(String arg5, String[] arg6) {
        if(arg6 != null) {
            String v0 = TextUtils.join("\n", ((Object[])arg6));
            if(Logger.debug()) {
                Logger.d("SharePreferenceCacheHandler", "cacheStringArray key = " + arg5 + " value = " + v0);
            }

            this.g(arg5, v0);
        }
    }

    protected final String[] b(String arg5) {
        String[] v0_1;
        String v0 = this.c(arg5);
        if(TextUtils.isEmpty(((CharSequence)v0))) {
            v0_1 = null;
        }
        else {
            if(Logger.debug()) {
                Logger.d("SharePreferenceCacheHandler", "getCachedStringArray key = " + arg5 + " value = " + v0);
            }

            v0_1 = v0.split("\n");
        }

        return v0_1;
    }

    private String c(String arg3) {
        return this.a.getString(arg3, null);
    }

    private void g(String arg2, String arg3) {
        if(!TextUtils.isEmpty(((CharSequence)arg3))) {
            SharedPreferences.Editor v0 = this.a.edit();
            v0.putString(arg2, arg3);
            v0.apply();
        }
    }
}

